module.exports = {
    data: {
        
    },
    set_ad() {
      console.log(`开始加载广告`)
      const ad = require('@service.ad')
      console.log(`服务提供商:${ad.getProvider()}`)
      if (!ad || !ad.createNativeAd) {
        console.log(`ad或createNativeAd方法无效`)
        return
      }
      const ad_id = `34b13c53bb3910a1d61075f86383ea9d`
      const nativeAdvObj = ad.createNativeAd({
        // 创建获取原生广告的对象
        adUnitId: ad_id
      })
      if (typeof nativeAdvObj !== 'object') {
        console.log(`nativeAdvObj非object对象`)
        console.log(nativeAdvObj)
      }
      // nativeAdvObj.id = ad_id //记录所使用的广告位id
      nativeAdvObj.onLoad(res => {
        // 获取广告成功
        console.log('广告组件--原生广告加载成功')
        console.log(res)
      })
      nativeAdvObj.onError(err => {
        console.log(`获取广告加载失败`)
        console.log(err)
      })
      nativeAdvObj.load() // 获取广告
    },
    async onInit() {
      // this.set_ad()
    }
}
